﻿//求⼀个整数存储在内存中的⼆进制中1的个数
#include <stdio.h>
int main()
{
	int num = -1;
	int i = 0;
	int count = 0;//计数 
	while (num)
	{
		count++;
		num = num & (num - 1);
	}
	printf("⼆进制中1的个数 = %d\n", count);
	return 0;
}



//⼆进制位置0或者置1
//编写代码将13⼆进制序列的第5位修改为1，然后再改回0
#include <stdio.h>
int main()
{
	int a = 13;
	a = a | (1 << 4);
	printf("a = %d\n", a);
	a = a & ~(1 << 4);
	printf("a = %d\n", a);
	return 0;
}
